<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="4">
            <a-tooltip placement="topLeft" overlayClassName="custom-tooltip">
              <template slot="title">
                <p style="margin-bottom: 0">查询技巧：</p>
                <p style="margin-bottom: 0">1.多选查询：多个查询字段之间用逗号","分隔。</p>
                <span>例如：</span>
                <span style="margin-bottom: 0;color: greenyellow">CP.000002，SC.000002</span>
              </template>
              <a-form-item label="物料代码">
                <a-input placeholder="请输入物料代码" v-model="queryParam.materialCode"></a-input>
              </a-form-item>
            </a-tooltip>
          </a-col>
          <a-col :md="6" :sm="4">
            <a-tooltip arrow-point-at-center>
              <template slot="title">
                <p style="margin-bottom: 0">查询技巧：</p>
                <p style="margin-bottom: 0">
                  1.多选查询：多个查询字段之间用逗号","分隔。例如：
                  <span style="color: greenyellow">散热器，喷涂件</span>
                </p>
                <p style="margin-bottom: 0">
                  2.模糊查询：一个查询字段之间用管道符号"|"分隔。例如：
                  <span style="color: greenyellow">散热器|喷涂件</span>
                </p>
              </template>
              <a-form-item label="物料名称">
                <a-input placeholder="请输入物料名称" v-model="queryParam.materialName"></a-input>
              </a-form-item>
            </a-tooltip>
          </a-col>
          <a-col :md="6" :sm="4">
            <a-form-item label="物料类型">
              <j-multi-select-tag v-model="queryParam.materialType" dictCode="hf_material_type,material_type_name,id" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="4">
            <a-form-item label="物料仓库">
              <j-multi-select-tag v-model="queryParam.warehouse" dictCode="hf_warehouse,warehouse_name,id" />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button icon="search" type="primary" @click="searchQuery">查询</a-button>
      <a-button icon="reload" type="primary" @click="searchReset">重置</a-button>
      <a-button icon="plus" type="primary" @click="handleAdd">新增</a-button>
      <a-button icon="download" type="primary" @click="handleExportXls(`物料全部信息`)">导出当前全部数据</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="materialCode"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
      </a-table>
    </div>

    <hf-material-modal ref="modalForm" @ok="modalFormOk"></hf-material-modal>
  </a-card>
</template>

<script>
import HfMaterialModal from '@views/material/modules/HfMaterialModal.vue'
import dayjs from 'dayjs'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'HfMaterialInformation',
  components: { HfMaterialModal },
  mixins: [JeecgListMixin],
  data() {
    return {
      description: '物料管理页面',
      // 表头
      columns: [
        {
          title: '物料代码',
          align: 'center',
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName'
        },
        {
          title: '规格型号',
          align: 'center',
          dataIndex: 'sap'
        },
        {
          title: '物料类型',
          align: 'center',
          dataIndex: 'materialType_dictText'
        },
        {
          title: '物料计量单位',
          align: 'center',
          dataIndex: 'unit_dictText'
        },
        {
          title: '单箱数',
          align: 'center',
          dataIndex: 'perNumber'
        },
        {
          title: '默认仓库',
          align: 'center',
          dataIndex: 'warehouse_dictText'
        },
        {
          title: '采购价格',
          align: 'center',
          dataIndex: 'purchasePrice'
        },
        {
          title: '采购-供应商品番',
          align: 'center',
          dataIndex: 'purchaseCode'
        },
        {
          title: '采购-简号',
          align: 'center',
          dataIndex: 'purchaseCode1'
        },
        {
          title: '销售价格',
          align: 'center',
          dataIndex: 'salePrice'
        },
        {
          title: '销售-客户品番',
          align: 'center',
          dataIndex: 'saleCode'
        },
        {
          title: '销售-简号',
          align: 'center',
          dataIndex: 'saleCode1'
        }
      ],
      url: {
        list: '/material/hfMaterial/AllInformation',
        delete: '/material/hfMaterial/delete',
        deleteBatch: '/material/hfMaterial/deleteBatch',
        exportXlsUrl: '/material/hfMaterial/allInformationExportXls',
        importExcelUrl: 'material/hfMaterial/importExcel'
      },
      dictOptions: {},
      superFieldList: []
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    dayjs() {
      return dayjs
    },
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    initDictConfig() {}
  }
}
</script>

<style scoped></style>
